home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / gdb.new / gdb-4.0 / bfd / m88k-bcs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-24  |  3.7 KB  |  123 lines

  1. /* Motorola 88000 COFF support ("Binary Compatability Standard") for BFD.
  2.    Copyright (C) 1990-1991 Free Software Foundation, Inc.
  3.    Written by Cygnus Support.
  4.  
  5. This file is part of BFD, the Binary File Descriptor library.
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. /* $Id: m88k-bcs.c,v 1.12 1991/07/31 16:57:52 gnu Exp $ */
  22.  
  23. #define M88 1
  24. #include <ansidecl.h>
  25. #include <sysdep.h>
  26. #include "bfd.h"
  27. #include "libbfd.h"
  28. #include "obstack.h"
  29. #include "m88k-bcs.h"
  30. #include "internalcoff.h"
  31. #include "libcoff.h"
  32.  
  33. /* Provided the symbol, returns the value reffed */
  34. #define HOWTO_PREPARE(relocation, symbol)     \
  35.   {                        \
  36.   if (symbol != (asymbol *)NULL) {        \
  37.     if (symbol->flags & BSF_FORT_COMM) {    \
  38.       relocation = 0;                \
  39.     }                        \
  40.     else {                    \
  41.       relocation = symbol->value;        \
  42.     }                        \
  43.   }                        \
  44.   if (symbol->section != (asection *)NULL) {    \
  45.     relocation += symbol->section->output_section->vma +    \
  46.       symbol->section->output_offset;        \
  47.   }                        \
  48. }            
  49.  
  50.  
  51.  
  52. static bfd_reloc_status_enum_type 
  53. DEFUN(howto_hvrt16,(abfd, reloc_entry, symbol_in, data, ignore_input_section),
  54. bfd *abfd AND
  55. arelent *reloc_entry AND
  56. asymbol *symbol_in AND
  57. unsigned char *data AND
  58. asection *ignore_input_section)
  59. {
  60.   long relocation;
  61.   bfd_vma addr = reloc_entry->address;
  62.   long x = bfd_get_16(abfd, (bfd_byte *)data + addr);
  63.  
  64.   HOWTO_PREPARE(relocation, symbol_in);
  65.  
  66.   x = (x + relocation + reloc_entry->addend) >> 16;
  67.  
  68.   bfd_put_16(abfd, x, (bfd_byte *)data + addr);
  69.   return bfd_reloc_ok;
  70. }
  71.  
  72.  
  73.  
  74. static reloc_howto_type howto_table[] = 
  75. {
  76.   HOWTO(R_PCR16L,02,1,16,true, 0,false,true,0,"PCR16L",false,0x0000ffff,0x0000ffff,true),
  77.   HOWTO(R_PCR26L,02,2,16,true, 0,false,true,0,"PCR26L",false,0x03ffffff,0x03ffffff,true),
  78.   HOWTO(R_VRT16, 00,1,16,false,0,false,true,0,"VRT16", false,0x0000ffff,0x0000ffff,true),
  79.   HOWTO(R_HVRT16,16,1,16,false,0,false,true,howto_hvrt16,"HVRT16",false,0x0000ffff,0x0000ffff,true),
  80.   HOWTO(R_LVRT16,00,1,16,false,0,false,true,0,"LVRT16",false,0x0000ffff,0x0000ffff,true),
  81.   HOWTO(R_VRT32, 00,2,32,false,0,false,true,0,"VRT32", false,0xffffffff,0xffffffff,true),
  82. };
  83.  
  84.  
  85.  
  86. #define BADMAG(x) MC88BADMAG(x)
  87. #include "coffcode.h"
  88.  
  89.  
  90.  
  91.  
  92. #define coff_write_armap bsd_write_armap
  93.  
  94.  
  95. bfd_target m88k_bcs_vec =
  96. {
  97.   "m88kbcs",            /* name */
  98.   bfd_target_coff_flavour_enum,
  99.   true,                /* data byte order is big */
  100.   true,                /* header byte order is big */
  101.  
  102.   (HAS_RELOC | EXEC_P |        /* object flags */
  103.    HAS_LINENO | HAS_DEBUG |
  104.    HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT),
  105.  
  106.   (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
  107.   '/',                /* ar_pad_char */
  108.   15,                /* ar_max_namelen */
  109.   3,                /* default alignment power */
  110.   _do_getb64, _do_putb64,  _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */
  111.   _do_getb64, _do_putb64,   _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */
  112.  
  113.     {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
  114.        bfd_generic_archive_p, _bfd_dummy_target},
  115.     {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
  116.        bfd_false},
  117.     {bfd_false, coff_write_object_contents, /* bfd_write_contents */
  118.        _bfd_write_archive_contents, bfd_false},
  119.  
  120.   JUMP_TABLE(coff),
  121.   COFF_SWAP_TABLE
  122. };
  123.